package com.xeem.core.net
{
	/**
	 * 单例socket
	 * @version 1.0
	 * @fp version 9+
	 */
	
	public class SingletonSocket extends Socket
	{
		private static var _this:SingletonSocket;
		private static var isSingleton:Boolean = false;
		
		public function SingletonSocket(host:String = "localhost", port:uint = 7777, delay:uint = 5) 
		{
			if (!isSingleton)
			{
				trace("只能用getInstance()来获取实例");
			}
			else
			{
				//init point
				super(host, port, delay);
			}
			isSingleton = false;
		}
		
		/**
		 * 生成单例
		 * @return  SingletonSocket
		 */
		public static function getInstance(host:String = "localhost", port:int = 7777, delay:uint = 5):SingletonSocket
		{
			if (_this == null)
			{
				isSingleton = true;
				_this = new SingletonSocket(host, port, delay);
			}
			return _this;
		}
	}
}